package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoLocation;
import com.ruoyi.info.service.IFhInfoLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 用户定位管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/info/location")
public class FhInfoLocationController extends BaseController
{
    @Autowired
    private IFhInfoLocationService fhInfoLocationService;

    /**
     * 查询用户定位管理列表
     */
    @PreAuthorize("@ss.hasPermi('info:location:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoLocation fhInfoLocation)
    {
        startPage();
        List<FhInfoLocation> list = fhInfoLocationService.selectFhInfoLocationList(fhInfoLocation);
        return getDataTable(list);
    }

    /**
     * 导出用户定位管理列表
     */
    @PreAuthorize("@ss.hasPermi('info:location:export')")
    @Log(title = "用户定位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoLocation fhInfoLocation) throws IOException {
        List<FhInfoLocation> list = fhInfoLocationService.selectFhInfoLocationList(fhInfoLocation);
        ExcelUtil<FhInfoLocation> util = new ExcelUtil<FhInfoLocation>(FhInfoLocation.class);
        util.exportExcel(response, list, "用户定位管理数据");
    }

    /**
     * 获取用户定位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:location:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoLocationService.selectFhInfoLocationById(id));
    }

    /**
     * 新增用户定位管理
     */
    @PreAuthorize("@ss.hasPermi('info:location:add')")
    @Log(title = "用户定位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoLocation fhInfoLocation)
    {
        return toAjax(fhInfoLocationService.insertFhInfoLocation(fhInfoLocation));
    }

    /**
     * 修改用户定位管理
     */
    @PreAuthorize("@ss.hasPermi('info:location:edit')")
    @Log(title = "用户定位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoLocation fhInfoLocation)
    {
        return toAjax(fhInfoLocationService.updateFhInfoLocation(fhInfoLocation));
    }

    /**
     * 删除用户定位管理
     */
    @PreAuthorize("@ss.hasPermi('info:location:remove')")
    @Log(title = "用户定位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoLocationService.deleteFhInfoLocationByIds(ids));
    }
}
